<?
$currentRound = getCurrentRound();
$round = $currentRound;
if (isset($_GET['round'])) {
	$round = $_GET['round'];
}

$isCurrent = false;
if ($currentRound == $round) {
	$isCurrent = true;
}
$teamPlayerScores = getTeamScoresByAverage($leagueId, $round);
$lastRound = -1;
?>
<script>
function goToRound() {
	document.location.href = "homePage.php?round=" + document.getElementById("roundVal").options[document.getElementById("roundVal").selectedIndex].value + "#tabs-DisplayRound";
}
</script>
<br>
<br>
<br>
<table>
		<!--tr>
			<td><select id="roundVal">
				<option value="2">2</option>
				<option value="3">3</option>
				<option value="4">4</option>
				<option value="5">5</option>
				<option value="6">6</option>
				<option value="7">7</option>
				<option value="8">8</option>
				<option value="9">9</option>
				<option value="10">10</option>
				<option value="14">14</option>
				<option value="15">15</option>
				<option value="16">16</option>
				<option value="17">17</option>
				<option value="18">18</option>
				<option value="19">19</option>
			</select>&nbsp;<input type="button" value="Go" onclick="goToRound()">
		</td> 
		</tr-->		
		<tr>
			<td><h2>Overall</h2></td><td><h2>Top 15</h2></td><td><h2>Over 30</h2></td> 
		</tr>
		<tr><td><table>
	<?
	usort($teamPlayerScores, "comparePlayerScoreByAverageTotal");
	$count = count($teamPlayerScores);
	for ($i = 0; $i < $count; $i++) {?>
	<tr>
		<td><?echo $teamPlayerScores[$i]->team->teamName?></td><td><?echo $teamPlayerScores[$i]->getAverageTotal()?></td>
	</tr>	
	<?}?>
	</table></td>
	<td><table>
	<?
	usort($teamPlayerScores, "comparePlayerScoreByAverageTop15");
	$count = count($teamPlayerScores);
	for ($i = 0; $i < $count; $i++) {?>
	<tr>
		<td><?echo $teamPlayerScores[$i]->team->teamName?></td><td><?echo $teamPlayerScores[$i]->getAverageTop15()?></td>
	</tr>	
	<?}?>
	</table></td>
<td><table>
	<?
	usort($teamPlayerScores, "comparePlayerScoreByAverageAbove30");
	$count = count($teamPlayerScores);
	for ($i = 0; $i < $count; $i++) {?>
	<tr>
		<td><?echo $teamPlayerScores[$i]->team->teamName?></td><td><?echo $teamPlayerScores[$i]->getAverageAbove30()?></td>
	</tr>	
	<?}?>
	</table></td>	
	</tr>
	<tr>
	<td colspan="3"><br><br><hr>
	
	<table width="100%"><tr>
		<?
		for ($i = 0; $i < $count; $i++) {
			if ($i == 3 || $i == 6 || $i == 9 || $i == 12 || $i == 15) {?>
				</tr><tr>
			<?}?>
			<td width="33%" valign="top"><table>
			<tr><td><h2><?echo $teamPlayerScores[$i]->team->teamName?></h2></td></tr>
			<?
			$count2 = count($teamPlayerScores[$i]->playerScores);
			for ($j = 0; $j < $count2; $j++) {
				if ($teamPlayerScores[$i]->playerScores[$j]->score > 0) {
			?>
			<tr><td><?echo getPlayerDisplayForPlayer($teamPlayerScores[$i]->playerScores[$j]->player)?></td><td><?echo $teamPlayerScores[$i]->playerScores[$j]->score?></td></tr>				
			<?}
			}?>
			</table>
			</td>
		<?}?>
		</tr>
		</table>	
	</td>
	</tr>
	</table>	

